import { QuickOptAlertPanel } from "./QuickOptAlertPanel";
import { Language } from "../../../../../extend/language/Language";
import { ItemData } from "../../../resource/info/ItemData";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
import { Cache } from "../../../cache/Cache";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { EffectManager } from "../../../manager/EffectManager";
import { MaskInfo } from "../../effect/MaskInfo";
import { GuideArrowManager } from "../../../manager/GuideArrowManager";
//class TopStrengthenPanel
    
    export  class TopStrengthenPanel extends QuickOptAlertPanel
    {
        constructor()
        {
            super();
            this.title = Language.getString(60312);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            _warmLabel.htmlText = Language.getString(61056);
            return;
        }

        public /* override */ set imageItemData(arg1: ItemData)
        {
            var loc1=0;
            super.imageItemData = arg1;
            if (arg1.itemExInfo && (arg1.itemExInfo.strengthen == 0 || arg1.itemExInfo.perfectStrengthen == 100)) 
            {
                loc1 = arg1.itemExInfo.strengthen + 1;
            }
            else if (arg1.itemExInfo) 
            {
                loc1 = arg1.itemExInfo.strengthen;
            }
            _nameLabel.htmlText = Language.getString(61057) + ItemsUtil.getItemName(arg1);
            _targetLabel.htmlText = Language.getStringByParam(61058, loc1);
            showWarmLabel(Cache.instance.equipment.isAutoBuy);
            return;
        }

        protected /* override */ onButtonClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=arg1.target;
            switch (loc1) 
            {
                case _btnOK:
                {
                    this.dispatchEvent(new DataEvent(EventName.Equipment_OnTopAddition, _imageItem.itemData));
                    break;
                }
            }
            super.onButtonClick(arg1);
            this.guideHide();
            return;
        }

        public guideEquipReq(): void
        {
            EffectManager.hideUIMask();
            var loc1=new MaskInfo();
            loc1.x = this.x + _btnOK.x;
            loc1.y = this.y + _btnOK.y;
            loc1.width = _btnOK.width;
            loc1.height = _btnOK.height;
            EffectManager.addUIMask([loc1]);
            var loc2=GuideArrowManager.getGuideArrow(GuideArrowManager.Dir_R, null, 0);
            loc2.x = _btnOK.x;
            loc2.y = _btnOK.y + _btnOK.height / 2;
            $addChild(loc2);
            return;
        }

        /* internal  */guideHide(): void
        {
            if (GuideArrowManager.guideArrow.parent == this) 
            {
                EffectManager.hideUIMask();
                GuideArrowManager.hideGuideArrow();
            }
            return;
        }
    }
